#ifndef SERIAL_H
#define SERIAL_H

#include <avr/io.h>

#define SERIAL_IN_BUFFER 32

// 10 bytes
typedef struct {
  uint8_t in_head, in_tail;
  uint8_t in[SERIAL_IN_BUFFER];
} Serialt, *Serialp;

void serial_init(Serialp serial);

/**
 * Returns 1 if byte was read 
 *   0 if no bytes available
 */
int8_t serial_read(Serialp serial, uint8_t *ch);

/*
 * doesn't return until byte is written
 */
void serial_write(Serialp serial, uint8_t ch);

#endif // SERIAL_H
